//	ID : pallab81
// 	PROG : 10891
// 	LANG : C++
// 	2011-09-08-16.37.08 Thursday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define fo(i,ed) foR( i , 0 , ed )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ) {
    double endtime = clock()+( seconds* CLOCKS_PER_SEC );
    while( clock() < endtime ) {
        ;
    }
}

int n;
int vi[101];
int dp[115][115];
Int vis[115][115];

inline void Read() {
    fo(i,n) {
        CI(vi[i]);
    }
}
inline int go(int st, int ed) {

    if( st>ed ) {
        return 0;
    }

    if( vis[st][ed] ) {
        return dp[st][ed];
    }
    vis[st][ed]=1;

    int best= (int)-1e9;
    int sum1=0;
    for(int i=st; i<=ed; ++i) {
        sum1+=vi[i];
        best = max(best, sum1 - go(i+1, ed ) );
    }
    int sum2=0;
    for(int i=ed; i>=st; --i) {
        sum2+=vi[i];
        best = max(best, sum2 - go(st, i-1) );
    }

    dp[st][ed]=best;
    return best;
}
inline void Proc() {
    SET(vis,0);
    int var = go(0,n-1);
    cout<<var<<"\n";
}
int main() {
//    #ifndef ONLINE_JUDGE
//        freopen("in.txt","rt",stdin);
//    #endif

    while( scanf("%d",&n)==1 && n!=0 ) {
        Read();
        Proc();
    }

    return 0;
}
